let {User}=require('../models');

let index_fn=async (ctx,next)=>{
    ctx.render('index.html');
};
let login_fn=async (ctx,next)=>{
    ctx.render('login.html');
};
let register_fn=async (ctx,next)=>{
    ctx.render('register.html',{msg:''});
};
let loginDone_fn=async (ctx,next)=>{
    
};
let registerDone_fn=async (ctx,next)=>{
    let uid=ctx.request.body.username || '';
    let pwd=ctx.request.body.password || '';
    let confirmpwd=ctx.request.body.confirmpassword || '';
    console.log(uid);
    console.log(pwd);
    console.log(confirmpwd);

    let u1=User.create({
        username:uid,
        password:pwd
    });
    console.log(JSON.stringify(u1));

    // return {age:3};
    ctx.body=JSON.stringify({age:3});

    // if(uid.length>0 &&pwd.length>0 && pwd===confirmpwd){
    //     let u1=User.create({
    //         username:uid,
    //         password:pwd
    //     });
    //     console.log(JSON.stringify(u1));
    // }else{
    //     ctx.render('register.html',{msg:'用户名或密码。。。。。'})
    // }
};


module.exports={
    '/':['get',index_fn],
    '/login':['get',login_fn],
    '/register':['get',register_fn],
    '/loginDone':['post',loginDone_fn],
    '/registerDone':['post',registerDone_fn],
}